//
//  MHTokenListCell.m
//  M-Saler
//
//  Created by Teresa on 2020/5/21.
//  Copyright © 2020 Teresa. All rights reserved.
//

#import "MHTokenListCell.h"
#import "MHTokenModel.h"

@interface MHTokenListCell()
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *descrLabel;
@property (weak, nonatomic) IBOutlet ZKPropertyButton *tailBtn;
@end

@implementation MHTokenListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

-(void)setModel:(MHTokenModel *)model{
    _model = model;
    self.nameLabel.text = model.code;
    [self switchBtnState:model.status];
}

+(CGFloat)height{
    return 76.f;
}

-(void)switchBtnState:(NSString*)state{
    DLog(@"state : %d",state);
    if ([state isEqualToString:@"0"]) {
        self.descrLabel.text = @"可用";
        self.descrLabel.textColor = MH_Red_Color;
        [self.tailBtn setTitle:@"发送" forState:UIControlStateNormal];
        self.tailBtn.borderColor = MH_Red_Color;
        [self.tailBtn setTitleColor:MH_Red_Color forState:UIControlStateNormal];
    }else{
        self.descrLabel.text = [NSString stringWithFormat:@"已关联:%@",self.model.phone];
        self.descrLabel.textColor = MH_Gray_Color;
        [self.tailBtn setTitle:@"查看" forState:UIControlStateNormal];
        self.tailBtn.borderColor = MH_Green_Color;
        [self.tailBtn setTitleColor:MH_Green_Color forState:UIControlStateNormal];
    }
//    switch (state) {
//        case 0:
//        {
//            self.descrLabel.text = @"可用";
//            self.descrLabel.textColor = MH_Red_Color;
//            [self.tailBtn setTitle:@"发送" forState:UIControlStateNormal];
//            self.tailBtn.borderColor = MH_Red_Color;
//            [self.tailBtn setTitleColor:MH_Red_Color forState:UIControlStateNormal];
//        }
//            break;
//            
//        default:
//        {
//            self.descrLabel.text = [NSString stringWithFormat:@"已关联:%@",self.model.phone];
//            self.descrLabel.textColor = MH_Gray_Color;
//            [self.tailBtn setTitle:@"查看" forState:UIControlStateNormal];
//            self.tailBtn.borderColor = MH_Green_Color;
//            [self.tailBtn setTitleColor:MH_Green_Color forState:UIControlStateNormal];            
//        }
//            break;
//    }
}

- (IBAction)btnClicked:(UIButton *)sender {
    if (self.btnClickBlock) {
        self.btnClickBlock();
    }
}

@end
